<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../../config.inc.php");

$_LangPath = "usercredit";	//語言檔參數，務必放在最前面
include_once(__Admin_Path."/logincheck.php");
include_once(__Language_Path."/selectlanguage_admin.php");
include_once(__Modules_Path."/Member.lib.php");

$strType = trim($_data["Type"]);
$strOP = trim($_data["op"]);
$strAuthCode = trim($_data["AuthCode"]);

$arrUser = getUserDataArrayByID($_SESSION["Admin_Info"] -> ID);
if($arrUser === false)ErrMsgOutputHTML("Error1", "", 1);

$strMType = "";
$strMData = "";
switch($strType){
	case "SkypeAcc":
		$strMData = $arrUser["SkypeAcc"];
		$strMType = "skype";
		break;

	case "Email":
		$strMData = $arrUser["Email"];
		$strMType = "email";
		break;

	case "MSN":
		$strMData = $arrUser["MSN"];
		$strMType = "msn";
		break;

	case "QQNum":
		$strMData = $arrUser["QQNum"];
		$strMType = "qq";
		break;

	case "MPhone":
		$arrMP = explode("-", $arrUser["MPhone"]);
		$strMData = "+".$arrMP[0]."".$arrMP[1];
		$strMType = "sms";
		break;
}

$strData = "";
if($strOP == "MoreAuth"){
	$strAuthCode = getAuthCode();
	//設定認證碼
	if(!setUserAuthCode($_SESSION["Admin_Info"] -> ID, $strType, $strAuthCode))ErrMsgOutputHTML("Error2", "RebackError", 1);
	//發送認證碼
	if(!sendUserAuthCode($_SESSION["Admin_Info"] -> Account, $strMType, $strMData, $strAuthCode))ErrMsgOutputHTML("Error3", "RebackError", 1);

	$strSuccess = $_strUserCredit["MoreAuthed"];
	$strData = $_strUserCredit["NoAuth"];

}else{
	$intResult = checkUserAuthCode($_SESSION["Admin_Info"] -> ID, $strType, $strAuthCode);
	if($intResult === false)ErrMsgOutputHTML("Error4", "RebackError", 1);
	
	$strSuccess = ($intResult)?$_strUserCredit["AuthSuccess"]:$_strUserCredit["AuthError"];
	if($intResult)$strData = $_strUserCredit["Authed"];
}
?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> Success </title>
<script language="JavaScript">
<!--
var strType = "<?php print $strType;?>";
alert("<?php print $strSuccess;?>");
parent.document.getElementById(strType + "Auth").disabled = false;
parent.document.getElementById(strType + "CheckStatus").innerHTML = "<div style='color: #FF0000; font-weight: 700'><?php print $_strUserCredit["NoAuth"];?></div>";
<?php if($intResult){ ?>
parent.document.getElementById(strType + "CheckStatus").innerHTML = "<?php print $strData;?>";
parent.document.getElementById(strType + "Auth").disabled = true;
parent.close_auth_win();
<?php } ?>
//-->
</script>
</head>
</html>